
<%@ page import="gfo.Stage" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'stage.label', default: 'Stage')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="body">
            <h1>${stageInstance.name}</h1>
            See the <a href="http://www.ssbwiki.com/${stageInstance.name}">Smash wiki</a> for more info.
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <!--Descriptions here-->
            <!--Nothing fancy here--just making use of the mostWonBy and MostPlayedBy methods for Stage.
            You may also notice that each stage has the same picture--this is because I have yet to
            specify a 'picFilename' attribute for Stage.-->
            <div class="dialog">
                <table>
                    <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                            ${stageInstance.name}
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <img src="/GFO/images/gf_res/${stageInstance.name.toLowerCase()}.jpg"
                                 alt="${stageInstance.name}" title="${stageInstance.name}" border="0" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">Description</td>
                        <td valign="top" class="value">${stageInstance.description}
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">Most Played By:</td>
                        <td valign="top" class="value">
                            <g:set var="mPB" value="${stageInstance.mostPlayedBy()}"></g:set>
                            <g:if test="${mPB}">
                                <g:link controller="player" action="show" id="${mPB?.id}">
                                    ${stageInstance.mostPlayedBy()?.fullName.encodeAsHTML()}
                                </g:link>
                            </g:if>
                            <g:else>
                                NA
                            </g:else>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">Most Won By:</td>
                        <td valign="top" class="value">
                            <g:set var="mWB" value="${stageInstance.mostWonBy()}"></g:set>
                            <g:if test="${mWB}">
                                <g:link controller="player" action="show" id="${mWB?.id}">
                                    ${stageInstance.mostWonBy()?.fullName.encodeAsHTML()}
                                </g:link>
                            </g:if>
                            <g:else>
                                NA
                            </g:else>
                        </td>
                    </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">Matches</td>
                            
                            <td valign="top" style="text-align: left;" class="value">
                                <ul>
                                <g:each in="${stageInstance.matches}" var="m">
                                    <li><g:link controller="match" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link></li>
                                </g:each>
                                </ul>
                            </td>
                            
                        </tr>
                    
                    </tbody>
                </table>
            </div>
            <div class="buttons">
                <g:form>
                    <g:hiddenField name="id" value="${stageInstance?.id}" />
                    <!--Again, edit only applicable for info purposes-->
                    <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </g:form>
            </div>
        </div>
    </body>
</html>
